import pymysql

# 打开数据库连接
conn = pymysql.connect(host='localhost', user="root", passwd="root", db="siya")
conn.select_db('face_detect')


def check_username():
    # 获取游标
    cur = conn.cursor()
    sql = "select * from user where username=%s"
    cur.executemany(sql, ["asd"])
    print(len(cur.fetchall()))

    cur.close()
    conn.commit()
    conn.close()
    print('sql执行成功')
    if len(cur.fetchall()) == 0:
        return 1
    else:
        return 0
